<template>
  <div>
        <el-form
              :inline="false"
              label-width="100px"
               :model="addauditIdForm"
              ref="auditIdFormRef"
            >
              <el-row :gutter="10">
                <el-col :span="10">
                  <div class="grid-content bg-purple">
                    <el-form-item label="员工编码" class="u-ipt">
                      <el-input
                        placeholder=""
                        v-model="addauditIdForm.staffCode"
                        class="input-with-select"
                      >
                      </el-input>
                    </el-form-item>
                  </div>
                </el-col>
                <el-col :span="10">
                  <div class="grid-content bg-purple">
                    <el-form-item label="员工姓名" class="u-ipt">
                      <el-input
                        placeholder="请输入内容"
                        v-model="addauditIdForm.staffName"
                        class="input-with-select"
                      >
                      </el-input>
                    </el-form-item>
                  </div>
                </el-col>
                <el-col :span="4">
                  <el-button
                    type="primary"
                    size="small"
                    @click="auditIdQuery"
                    >查询</el-button
                  >
                </el-col>
                 <el-col :span="24">
                        <el-form-item label="审核人姓名">
                            {{addauditIdForm.staffNameChoose}}
                        </el-form-item>    
                      </el-col>
              </el-row>
            </el-form>  

          <DicTable
              ref="commonRegionTable"
              stripe
              highlight-current-row
              :columnData="auditIdColumns"
              :tableData="auditIdTableData"
              :loading="auditIdTableLoading"
              :currentPage="auditIdTablePage.pageIndex"
              :pageSize="auditIdTablePage.pageSize"
              :totalResult="auditIdTablePage.rowCount"
              :pager="true"
              @current-change="auditIdCurrentChangeEvent"
              @on-page-change="auditIdHandlePageChange"
            >
            </DicTable> 
            <div class="text-c">
               <el-button
                    type="primary"
                    size="small"
                    @click="sunmitAuditIdHandel"
                    >确定</el-button
                  >
            </div>
  </div>
</template>

<script>
import DicTable from "@/components/public/DicTable";
import CustomerInfoManageServer from "@/api/customer/CustomerInfoManageServer";
import { mapState } from "vuex";
export default { 
  props: {
    value: [Number, String],
    title: [String],
    size: [String],
  },
  computed:{
    ...mapState("user", ["user"])
  },
  data() {
    return {
      addauditIdForm:{
        staffCode:"",//审核人编码
        staffName:"",//审核人名称
        staffNameChoose:"",
        staffCodeId:""//选择审核人编码存放变量
      },
      auditIdColumns:[
        { field: "STAFF_CODE", title: "员工编码",fixed:"left",showOverflow: true,width:100 },
        {
          field: "STAFF_NAME",
          title: "员工姓名",
          width: 200,
          fixed:"left",
          showOverflow: true,
        },
        { field: "MOBILE_PHONE", title: "员工联系方式",width:200},
        { field: "ORG_NAME", title: "组织名称",width:200},
        { field: "DEPARTMENT_NAME", title: "部门名称",width:200},
       
 
      ],
      auditIdTableData:[],
      auditIdTableLoading:false,
      auditIdTablePage:{
        pageIndex: 1,
        pageSize: 5,
        rowCount: 0,
        pageCount:0
      },
      
    };
  },
  mounted() {
    this.$nextTick(() => {
         this.auditIdAjax();
    });
  },
  components:{
    DicTable
  },
  methods: {
 // 点击审核人弹窗-确定将审核人的id带过来
    sunmitAuditIdHandel(){
      this.$emit('sunmitAuditIdHandel',[this.addauditIdForm.staffCodeId,this.addauditIdForm.staffNameChoose])
      // 
      //  this.ruleForm.auditId=this.addauditIdForm.staffCodeId;
      //  this.$refs.auditIdRef.drawer = false;
    },
    // 审核人查询方法
    auditIdQuery(){
      this.auditIdTablePage.pageIndex=1;
      this.auditIdTablePage.pageSize =5;
      this.auditIdAjax();
    },
     //新建客户-审核人点击方法
     auditIdAjaxHandel(row){
       this.auditIdTablePage.pageIndex=1;
       this.auditIdTablePage.pageSize=5;
       this.auditIdAjax();
      },
      subitForm(){
        this.isShow=false;
         this.$router.push("/custbaseinf");
      },
     // 新建客户-证件类型切换党政军-显示的审核人弹窗-点击行
    auditIdCurrentChangeEvent(val){
      
      
      this.addauditIdForm.staffNameChoose=val.data[val.$rowIndex].STAFF_NAME;
      this.addauditIdForm.staffCodeId=val.data[val.$rowIndex].STAFF_ID;

    },
    // 新建客户-证件类型切换党政军-显示的审核人弹窗-分页
    auditIdHandlePageChange(val){
      this.auditIdTablePage.pageIndex=val.currentPage;
      this.auditIdTablePage.pageSize = val.pageSize;
      this.auditIdAjax();
    },
    // 审核人的ajax-初始化
   async  auditIdAjax() {
      let params={
                   staffId:this.user.staffId,
                   pageIndex:this.auditIdTablePage.pageIndex,
                   pageSize:this.auditIdTablePage.pageSize,
                   staffCode:this.addauditIdForm.staffCode,
                   staffName:this.addauditIdForm.staffName
            };
       let res = await CustomerInfoManageServer.getAuditorList(params);
       if(res.code==200){
         this.auditIdTableData=res.meta.customers || []
         this.auditIdTablePage.rowCount=Number(res.meta.pageInfo.rowCount);
         this.auditIdTablePage.pageCount=Number(res.meta.pageInfo.pageCount)
       }else{
          this.$notify.error({
          title: '错误',
          message: response.msg
        });
       }
    },
    

  },
};
</script>
<style lang="scss" scoped>
.text-c{
  margin:0.2rem;
  text-align:center;
}
.el-footer {
  position: absolute;
  display: block;
  bottom: 5px;
  width: 100%;
}
.demo-drawer__footer {
  text-align: center;
  position: absolute;
  bottom: 0;
}
.demo-drawer__footer button {
  display: inline-block;
  width: 45%;
}
</style>
